package com.tokenplus.thai.utils

import android.annotation.SuppressLint
import com.tokenplus.thai.data.*
import com.tokenplus.thai.enums.CountryPathEnum
import com.tokenplus.thai.extend.*
import com.tokenplus.thai.anetwork.ApiUrl

/** 登录地区管理工具 */
object UsageCountryUtil {

    //sp country
    var mCountry: String = ""

    //sp api path
    var mApiPath: String = ""

    init {
        mCountry = SpUtil.getCountry()
        mApiPath = SpUtil.getApiPath()
    }

    /** 保存 country */
    @SuppressLint("ApplySharedPref")
    fun saveCountry(gCountry: String) {
        mCountry = gCountry
        SpUtil.saveCountry(gCountry)
    }

    /** 保存 api path */
    @SuppressLint("ApplySharedPref")
    fun saveApiPath(gApiPath: String) {
        mApiPath = gApiPath
        SpUtil.saveApiPath(gApiPath)
    }

    /** 注销退出 */
    fun logout() {
        saveCountry("")
        saveApiPath("")
    }

    /** 判断是否为尼日 */
    fun isCountryNigeria(): Boolean {
        if (mApiPath.contains(CountryPathEnum.rawwalletnaira.name, true)) {
            return true
        }
        return false
    }

    /** 判断是否为加纳 */
    fun isCountryGhana(): Boolean {
        if (mApiPath.contains(CountryPathEnum.rawwalletgha.name, true)) {
            return true
        }
        return false
    }

    /** 判断是否为肯尼亚 */
    fun isCountryKenya(): Boolean {
        if (mApiPath.contains(CountryPathEnum.rawwalletksh.name, true)) {
            return true
        }
        return false
    }

    /** 判断是否为乌干达 */
    fun isCountryUganda(): Boolean {
        if (mApiPath.contains(CountryPathEnum.rawwalletugx.name, true)) {
            return true
        }
        return false
    }

    /** 判断是否为科特 */
    fun isCountryCotediva(): Boolean {
        if (mApiPath.contains(CountryPathEnum.rawwalletfcfa.name, true)) {
            return true
        }
        return false
    }

    /** 判断是否为越南 */
    fun isCountryVietnam(): Boolean {
        if (mApiPath.contains(CountryPathEnum.rawwalletvnd.name, true)) {
            return true
        }
        return false
    }
}